Skip to content

fix: Use a single timestamp in server_info - #3156

Open
snowyukitty wants to merge 1 commit into
XRPLF:developfrom
snowyukitty:fix/server-info-single-timestamp
Open

fix: Use a single timestamp in server_info#3156
snowyukitty wants to merge 1 commit into
XRPLF:developfrom
snowyukitty:fix/server-info-single-timestamp

Conversation

@snowyukitty

Copy link
Copy Markdown

server_info sampled system_clock once when constructing InfoSection::time
and again when calculating validated_ledger.age. If those samples straddled a
whole-second boundary, the exact-age assertions could fail intermittently.

This change reuses the timestamp already stored in output.info.time for the
age calculation. The clock remains system_clock by default; making it
injectable lets the tests use fixed absolute ledger times and verify that
successful requests sample it exactly once. A regression test also preserves
the existing zero clamp for future close times.

Fix #2353

Testing

  • RPCServerInfoHandlerTest.*: 12 passed; repeated 100 times (1,200 executions)
  • Adjacent RPC handler and ledger tests: 75 passed
  • Full unit suite: 3,294 passed, 1 disabled
  • GCC 15.2 Release with -Werror; affected Clang 19 translation units
  • clang-format 22.1.8, clang-tidy, C++ pre-commit hooks, codespell, and Doxygen
    1.14.0

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@godexsoft godexsoft left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is great! just one nit and i think this is good to go 👍

auto const ledgerHeader = createLedgerHeaderWithUnixTime(kLedgerHash, 30, kNowUnix + 5);
runNormalRequest(ledgerHeader, [&](auto const& output) {
ASSERT_TRUE(output);
auto const& validated = output.result.value()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps some intermediate references here would make it look a little nicer 🔢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test in RPCServerInfoHandlerTest

2 participants